import { VxeGridPropTypes } from '@/components/VxeTable';
import { Tag } from 'ant-design-vue';
import { h } from 'vue';

export default [
  {
    title: '日志名称',
    field: 'displayTitle'
  },
  {
    title: '日志级别',
    field: 'logLevel',
    slots: {
      default: ({ row }) => {
        const logLevel = row.logLevel;
        switch (logLevel) {
          case 'Information':
            return h(Tag, { color: 'green' }, () => 'Information');
          case 'Warning':
            return h(Tag, { color: 'orange' }, () => 'Warning');
          case 'Error':
            return h(Tag, { color: 'red' }, () => 'Error');
          default:
            return h(Tag, { color: 'blue' }, () => '未知');
        }
      }
    }
  },
  {
    title: '事件Id',
    field: 'eventId'
  },
  {
    title: '日志消息',
    field: 'message'
  },
  {
    title: '浏览器',
    field: 'browser'
  },
  {
    title: '异常对象',
    field: 'exception'
  },
  {
    title: '操作时间',
    field: 'createTime',
    visible: false
  },
  {
    width: 160,
    title: '操作',
    align: 'center',
    slots: { default: 'action' },
    fixed: 'right'
  }
] as VxeGridPropTypes.Columns;
